package com.liyuncong.learn.learnberkeleydb;

import com.sleepycat.bind.tuple.TupleBinding;  
import com.sleepycat.bind.tuple.TupleInput;  
import com.sleepycat.bind.tuple.TupleOutput;  
 
public class PersonTupleBinding extends TupleBinding{  
 
   @Override  
   public Object entryToObject(TupleInput ti) {  
       Person person = new Person();  
       person.setName(ti.readString());  
       person.setAge(ti.readInt());  
       person.setSex(ti.readChar());  
       return person;  
   }  
 
   @Override  
   public void objectToEntry(Object obj, TupleOutput output) {  
       Person person = (Person)obj;  
       output.writeString(person.getName());  
       output.writeInt(person.getAge());  
       output.writeChar(person.getSex());  
   }  
} 
